<template>
    <div class="page-main DataDict">
        <DataTable ref="DictDataTableRef" :data="list" :has-top="false" :has-pager="false" :has-checkbox="false" :hasID="false" :has-seq="true" div-height="calc(100vh - 130px)" v-bind="$attrs">
            <vxe-column title="名称" min-width="120" show-overflow>
                <template #default="{ row }">
                    {{ row.text || "-" }}
                </template>
            </vxe-column>

            <vxe-column title="操作" min-width="100">
                <template #default="{ row }">
                    <el-button :disabled="row.isDelete" type="primary" @click="onOpenModule(row)">编辑</el-button>
                </template>
            </vxe-column>

            <!-- 在添加按钮后面的搜索条件 -->
            <template #otherFilter></template>

            <!-- 在搜索按钮后面的按钮 -->
            <template #otherBtn></template>

            <!-- 顶部右侧按钮 -->
            <template #rightBtn></template>

            <!-- 高级搜索内容 -->
            <template #Advfilter>
                <!-- <el-form v-model="filterModel" label-position="top" @submit.prevent></el-form> -->
            </template>
        </DataTable>

        <HoisterUsage ref="HoisterUsageRef" v-if="curDictID == Enums.Dict.提升用途" @close="onClose"></HoisterUsage>
        <WireropeType ref="WireropeTypeRef" v-if="curDictID == Enums.Dict.钢丝绳类型" @close="onClose"></WireropeType>
        <Mpa ref="MpaRef" v-if="curDictID == Enums.Dict.抗拉强度等级MPa" @close="onClose"></Mpa>
        <SurfaceStatus ref="SurfaceStatusRef" v-if="curDictID == Enums.Dict.表面状态" @close="onClose"></SurfaceStatus>
        <TwistingType ref="TwistingTypeRef" v-if="curDictID == Enums.Dict.捻制类型" @close="onClose"></TwistingType>
        <WireropeStruct ref="WireropeStructRef" v-if="curDictID == Enums.Dict.绳芯结构" @close="onClose"></WireropeStruct>
        <OperType ref="OperTypeRef" v-if="curDictID == Enums.Dict.入库类型 || curDictID == Enums.Dict.出库类型" @close="onClose"></OperType>
        <WireropeKeepType ref="WireropeKeepTypeRef" v-if="curDictID == Enums.Dict.在用绳维保类型" @close="onClose"></WireropeKeepType>
    </div>
</template>

<script lang="ts" setup>
import Enums from "@/gx/Enums";

import HoisterUsage from "@/views/dict/HoisterUsage/HoisterUsage.vue";
import WireropeType from "@/views/dict/WireropeType/WireropeType.vue";
import Mpa from "@/views/dict/Mpa/Mpa.vue";
import SurfaceStatus from "@/views/dict/SurfaceStatus/SurfaceStatus.vue";
import TwistingType from "@/views/dict/TwistingType/TwistingType.vue";
import WireropeStruct from "@/views/dict/WireropeStruct/WireropeStruct.vue";
import OperType from "@/views/dict/OperType/OperType.vue";
import WireropeKeepType from "@/views/dict/WireropeKeepType/WireropeKeepType.vue";

//表格数据
const list = ref(Enums.Dict.ToArray());

const curDictID = ref(0);

//向子组件传值
const inOutType = ref<number | null>(null);
provide("inOutType", inOutType);

const onOpenModule = (row) => {
    curDictID.value = row.value;

    switch (row.value) {
        case Enums.Dict.入库类型:
            inOutType.value = Enums.OperType_InOutType.入库;
            break;

        case Enums.Dict.出库类型:
            inOutType.value = Enums.OperType_InOutType.出库;
            break;
    }
};

const onClose = () => {
    curDictID.value = 0;
};
</script>
